//  [4/14/2013 OMEGA] created

#include "DuelREditorCommon.h"
#include "DuelREProjectWindow.h"

namespace DuelResourceEditor
{
	REProjectTreeItem::REProjectTreeItem( const QList<QVariant> &data, REProjectTreeItem* parent )
	{
		mParent = parent;
		mItemData = data;
	}

	REProjectTreeItem::~REProjectTreeItem()
	{
		qDeleteAll(mChildItems);
	}

	void REProjectTreeItem::appendChild( REProjectTreeItem* child )
	{
		mChildItems.append(child);
	}

	REProjectTreeItem* REProjectTreeItem::getChild( int index )
	{
		 return mChildItems.value(index);
	}

	int REProjectTreeItem::getChildrenCount() const
	{
		return mChildItems.count();
	}

	int REProjectTreeItem::getColumnCount() const
	{
		return mItemData.count();
	}

	QVariant REProjectTreeItem::data( int column ) const
	{
		return mItemData.value(column);
	}

	int REProjectTreeItem::row() const
	{
		if (mParent)
		{
			return mParent->mChildItems.indexOf(const_cast<REProjectTreeItem*>(this));
		}
		return 0;
	}

	REProjectTreeItem* REProjectTreeItem::getParent()
	{
		return mParent;
	}

}
